#include <bits/stdc++.h>

using namespace std;

#define int long long

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>cnt(26 , 0);
    for(auto c : s) cnt[c - 'a']++;
    int flag = 0;
    for(int i = 0;i < 26;i ++)
    {
        if(cnt[i] >= 3) flag = 1;
        else if(cnt[i] == 2 && (s[0] - 'a' != i || s.back() - 'a' != i)) flag = 1;

    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}
signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}